from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time

if __name__ == '__main__':
    path = "chromedriver.exe"
    liu = webdriver.Chrome(path)
    url = "https://mooc1.chaoxing.com/mycourse/studentstudy?chapterId=482774714&courseId=220564152&clazzid=46373175&enc=106cab0697ad30e1900a000a0dae6c53&mooc2=1&cpi=213385649&openc=b343722bb907de1761cbd122395f40f8"
    liu.get(url)
    time.sleep(30)
    liu.switch_to.frame("iframe")
    time.sleep(1)
    iframe = liu.find_element_by_xpath("//body//iframe")
    time.sleep(0.5)
    for i in range(1, 70000):
        ActionChains(liu).move_by_offset(12, 13).perform()
        ActionChains(liu).move_to_element_with_offset(iframe, 60, 500).click().perform()
        time.sleep(10)
    time.sleep(3600000)
